<?php 
session_start();

	include("../../conexion.php");
	
	require_once("../../includes/barramenu.php") ;
	require_once("../../includes/gridView.php")  ;
	require_once("../../includes/combo.php")  	  ;
	$oBarra = new BarraMenu() 				  ;
	$Grid1 = new GridView()					  ;
	$oCombo = new CmbList()  				  ;	
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ingreso de cartas</title>
<link href="../../includes/css/jquery-ui-notarios.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../tcal.css" />
<link href="../../includes/css/jquery-ui-notarios.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../includes/css/uniform.default.min.css" />
<link rel="stylesheet" type="text/css" href="../../tcal.css" />
<link rel="stylesheet" type="text/css" href="../includes/css/IngCartasVie.css" />

<script type="text/javascript" src="../../tcal.js"></script> 
<script type="text/javascript" src="../includes/Mantenimientos.js"></script> 
<script src="../../includes/jquery-1.8.3.js"></script>
<script src="../../includes/js/jquery-ui-notarios.js"></script>
<script src="../../includes/jquery.uniform.min.js"></script>
<script src="../../includes/maskedinput.js"></script>
<script type="text/javascript" src="../../tcal.js"></script> 
<script type="text/javascript" src="../includes/js/IngCartasVie.js"></script> 

<script type="text/javascript">
$(document).ready(function(){ 

	 $("button").button();
	 $("#dialog").dialog();
	 $("input, textarea").uniform();
	 $( "#dialog:ui-dialog" ).dialog( "destroy" );
	 
	})
	
	jQuery(function($){
		$("#fecentrega").mask("99/99/9999",{placeholder:"_"});
		$("#horaentrega").mask("99:99 aa",{placeholder:"_"});
		$("#fecrecogio").mask("99/99/9999",{placeholder:"_"});
		
	});
	
	function fEdita(){ feditaCarta(); }

	function fElimina()
	{
		var _numcarta = document.getElementById('numcarta').value;
		if(confirm('eliminar datos de la carta notarial N. '+_numcarta+' ?'))
		{	fElimCarta(); }	
		else{return;}
	}

	function fini(){	document.getElementById('idzona').value = '<?php echo $rowcarta['zona_destinatario']; ?>';	}


	function fmuescontenido()
	{
		var divobs = $('<div id="div_ayudacarta" title="div_ayudacarta"></div>');
		$('<div id="div_ayudacarta" title="div_ayudacarta"></div>').load('CartasAyuda.php')
		.dialog({
						autoOpen: true,
						position :["center","top"],
						width   : 550,
						height  : 250,
						modal:false,
						resizable:false,
						buttons: [{id: "btnaceptar", text: "Aceptar",click: function() {pasadatos();$(this).dialog("destroy").remove(); }},
						{text: "Cancelar",click: function() { $(this).dialog("destroy").remove(); }}],
						title:'Ayuda Cartas'
						
						}).width(550).height(250);	
						$(".ui-dialog-titlebar").hide();		
	}

	function newParticipante()
	{
		$('<div id="div_newpartic" title="div_newpartic"></div>').load('NewRemitente.php')
		.dialog({
						autoOpen: true,
						position :["center","top"],
						width   : 720,
						height  : 350,
						modal:false,
						resizable:false,
						buttons: [{id: "btnAcepPartic2", text: "Aceptar",click: function() {evalGuardaParticipante();$(this).dialog("destroy").remove(); }},
						{text: "Cancelar",click: function() {$(this).dialog("destroy").remove(); }}],
						title:'Agregar participantes'
						
						}).width(720).height(350);	
						$(".ui-dialog-titlebar").hide();		
	}

	function fImprimir()
	{
		var _num_carta = document.getElementById('numcarta').value;
		if(_num_carta==''){alert('Debe guardar los datos primero');return;}
	
		var _usuario_imprime = '<?php echo $_SESSION["apepat_usu"].' '.$_SESSION["nom1_usu"]; ?>';
		var _nom_notario     = 'NOMBRE DEL NOTARIO';
	
		var _data = {
						num_carta       : _num_carta,
						usuario_imprime : _usuario_imprime,
						nom_notario     : _nom_notario
					}
		
		
		$.post("../../reportes_word/generador_cartas.php",_data,function(_respuesta){
						alert(_respuesta);
					});
			
	}


    function fShowDatosProvee(evento)
		{			
			var _numdoc		= document.getElementById('numdoc').value;
			var _remitente  = document.getElementById('remitente');
			var _direccion  = document.getElementById('direccion_remi');
			var _telefono   = document.getElementById('telefono');
			
			if(evento.keyCode==13) 
				{
					if(_numdoc==''){alert('Ingrese un numero de documento');return;}
					
					var _des = fShowAjaxDato('../includes/remitente.php?numdoc='+_numdoc);
					document.getElementById('remitente').value = _des;
					
					var _direcc = fShowAjaxDato('../includes/direccion.php?numdoc='+_numdoc);
					document.getElementById('direccion_remi').value=_direcc;
					
					var _telf = fShowAjaxDato('../includes/telefono.php?numdoc='+_numdoc);
					document.getElementById('telefono').value=_telf;
					
					if(_remitente.value==''){alert('No se encuentra registrado');
					$('#numdoc').val('');
					$('#remitente').val('');
					$('#direccion_remi').val('');
					$('#telefono').val('');
					return; }
				}
		}


function fVisualDocument()
	{
		var eval_numcarta = document.getElementById('numcarta').value;
		
		if(eval_numcarta == ''){alert('Debe guardar los datos primero');return;}
		var _numcarta     = document.getElementById('muesnumcarta').value;
	
		var _usuario_imprime = '<?php echo $_SESSION["apepat_usu"].' '.$_SESSION["nom1_usu"]; ?>';
		var _nom_notario     = 'NOMBRE DEL NOTARIO';
		
		
//AjaxReturn('../../reportes_word/generador_permiviaje_interior.php?id_viaje='+_id_viaje+'&usuario_imprime='+_usuario_imprime+'&nom_notario='+_nom_notario);
		window.open("genera_carta.php?numcarta="+_numcarta+"&usuario_imprime="+_usuario_imprime+"&nom_notario="+_nom_notario);
			
	}

function remitente1(){
 valord=document.getElementById('remitente').value;
 textod=valord.replace(/&/g,"*");
 document.getElementById('remitente1').value=textod;

}
function direccionremi1(){
 valord=document.getElementById('direccion_remi').value;
 textod=valord.replace(/&/g,"*");
 document.getElementById('direccion_remi1').value=textod;

}
</script>
</head>

<body style="font-size:62.5%;">
<div id="carta_content">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td width="13%">
     <?php
				$oBarra->Graba        = "1"               ;
				$oBarra->GrabaClick   = "fGraba2();"      ;
				$oBarra->Impri        = "1"               ;
				$oBarra->ImpriClick   = "fImprimir();"    ;
				$oBarra->clase        = "css"      		  ; 
				$oBarra->widthtxt     = "20"			  ; 
				$oBarra->Show()  						  ; 
				?>
    </td>
       <td width="16%" align="left"> <button title="Crear Bloque" type="button" name="bloque"    id="bloque" value="bloque" onclick="fCreabloque();" ><img align="absmiddle" src="../../images/block.png" width="15" height="15" />Crear Bloque</button></td>
     <td width="71%"><div id="verdocumen"><button title="visualizar" type="button" name="btnver"    id="btnver" value="visualizar" onclick="fVisualDocument();" ><img align="absmiddle" src="../../images/block.png" width="15" height="15" />Ver</button></div></td>
  
   
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
  <tr>
    <td colspan="2"><table  width="100%">
      <tr>
        <td colspan="6"><div id="muesguarda" title="Confirmacion" style="display:none">Desea guardar la Carta..?</div><div id="confirmaGuarda"></div></td>
        </tr>
      <tr>
        <td width="14%"><span class="camposss">Nro carta:</span></td>
        <td width="16%"><div id="resul_carta" style="width:100px;"><input name="numcarta" type="hidden" id="numcarta" size="15" readonly="readonly" placeholder="Autogenerado" /></div></td>
        <td width="17%"><span class="camposss">Responsable:</span></td>
        <td width="33%"><input name="idencargado" type="text" id="idencargado" style="text-transform:uppercase" value="<?php echo $_SESSION["apepat_usu"].' '.$_SESSION["nom1_usu"]; ?>" size="15" readonly="readonly" />
          <input name="encargado" type="hidden" id="encargado" style="text-transform:uppercase" size="40" /></td>
        <td width="17%"><span class="camposss">Fecha ingreso:</span> </td>
        <td width="36%"><input name="fecingreso" type="text" id="fecingreso" style="text-transform:uppercase" value="<?php echo date("d/m/Y"); ?>" size="15" class="tcal" /></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2">
    <fieldset id="field_remitente">
    <legend><span class="camposss">Remitente</span></legend>
    <table  width="100%">
        <tr>
          <td width="14%"><span class="camposss">N.documento :</span></td>
          <td width="37%"><input name="numdoc" type="text" id="numdoc" style="text-transform:uppercase" onkeypress="fShowDatosProvee(event);" size="15" />&nbsp;
            <a href="#" onClick="newParticipante();//fShowDatosProveeClick()"> <img src="../../images/search.png" width="15" height="15" alt="" /></a>
           </td>
          <td width="19%"><span class="camposss">Telefono:</span></td>
          <td width="30%"><input name="telefono" type="text" id="telefono" style="text-transform:uppercase" size="15" maxlength="200" /></td>
        </tr>
        <tr>
          <td><span class="camposss">Remitente:</span> </td>
          <td colspan="3"><input name="remitente" type="text" id="remitente" style="text-transform:uppercase" size="60" onKeyUp="remitente1();" maxlength="400" />
          <input type="hidden" name="remitente1" id="remitente1" >
          </td>
          </tr>
        <tr>
          <td><span class="camposss">Direccion:</span> </td>
          <td colspan="3"><input name="direccion_remi" style="text-transform:uppercase" type="text" id="direccion_remi" size="60"  onKeyUp="direccionremi1();" maxlength="2000"/>
          <input type="hidden" name="direccion_remi1" id="direccion_remi1" >
          </td>
        </tr>
        </table>
    </fieldset>  
      </td>
    </tr>
  <tr>
    <td colspan="2">
    <fieldset id="field_destinatario">
    <legend><span class="camposss">Destinatario</span></legend>
    <table  width="100%">
        <tr>
          <td width="14%"><span class="camposss">Nombre:</span> </td>
          <td colspan="3"><input name="destinatario" type="text" id="destinatario" style="text-transform:uppercase" size="60" maxlength="400" /></td>
          </tr>
        <tr>
          <td><span class="camposss">Dir. destino</span></td>
          <td colspan="3"><input name="dirdestino" style="text-transform:uppercase" type="text" id="dirdestino" size="60" maxlength="2000" /></td>
          </tr>
        <tr>
          <td><span class="camposss">Zona:</span> </td>
          <td width="35%">
		  <?php 
			$oCombo = new CmbList()  ;					 		
			$oCombo->dataSource = "SELECT ubigeo.coddis AS 'id', ubigeo.nomdis AS 'descripcion' FROM ubigeo
ORDER BY ubigeo.nomdis ASC"; 
			$oCombo->value      = "id";
			$oCombo->text       = "descripcion";
			$oCombo->size       = "150"; 
			$oCombo->name       = "idzona";
			$oCombo->style      = "camposss"; 
			$oCombo->click      = "//selectzona(this.value);";   
			$oCombo->selected   =  $variable;
			$oCombo->Show();
			$oCombo->oDesCon(); 
?><input name="zonadestinatario" type="hidden" id="zonadestinatario" /></td>
          <td width="20%"><span class="camposss"><!--Costo:--></span> </td>
          <td width="31%"><input name="costo" type="hidden" id="costo" style="text-transform:uppercase" value="0.00" size="15" /></td>
        </tr>
        </table>
    </fieldset>
    
    </td>
    </tr>
  <tr>
    <td colspan="2">
    </td>
    </tr>
  <tr>
    <td colspan="2" >
    <fieldset id="field_diligencia">
    <legend><span class="camposss">Diligencia</span></legend>
    <table  width="100%">
        <tr>
          <td width="14%"><span class="camposss">Fec. Diligencia:</span></td>
          <td width="16%"><input name="fecentrega" type="text" id="fecentrega" style="text-transform:uppercase" size="15" class="tcal" /></td>
          <td width="8%"><span class="camposss">Hora:</span> </td>
          <td width="23%"><input name="horaentrega" type="text" id="horaentrega" style="text-transform:uppercase" size="15" /></td>
          <td width="7%"><span class="camposss">Por:</span></td>
          <td width="32%"><?php 
			$oCombo = new CmbList()  ;					 		
			$oCombo->dataSource = "SELECT usuarios.loginusuario AS 'id' ,CONCAT(usuarios.apepat,' ',usuarios.apemat, ', ',usuarios.prinom) AS 'des' FROM usuarios
ORDER BY usuarios.apepat ASC"; 
			$oCombo->value      = "id";
			$oCombo->text       = "des";
			$oCombo->size       = "150"; 
			$oCombo->name       = "empentrega";
			$oCombo->style      = "camposss"; 
			$oCombo->click      = "//selectzona(this.value);";   
			$oCombo->selected   =  $variable;
			$oCombo->Show();
			$oCombo->oDesCon(); 
?>
</td>
          </tr>
        </table>
    </fieldset>
    </td>
    </tr>
  <tr>
    <td width="92" height="30" valign="top" ><span class="camposss">Contenido:</span>
    <a href="#" onClick="fmuescontenido()"><img src="../../images/help.png" width="12" height="12" alt="" /></a>
      </td>
    <td width="545" height="30" ><label for="contecarta"></label>
      <textarea name="contecarta" id="contecarta" cols="110" rows="5" style="text-transform:uppercase;"></textarea></td>
    </tr>
  <tr>
    <td height="30" colspan="2" ><fieldset id="field_cargo">
      <legend><span class="camposss">CARGO DESTINATARIO</span></legend>
      <table  width="100%">
        <tr>
          <td width="14%"><span class="camposss">Recogio la carta:</span> </td>
          <td colspan="3"><input name="nomrecogio" type="text" id="nomrecogio" style="text-transform:uppercase" size="60" maxlength="400" /></td>
        </tr>
        <tr>
          <td><span class="camposss">Documento</span></td>
          <td width="35%"><input name="docrecogio" style="text-transform:uppercase" type="text" id="docrecogio" size="30" maxlength="40" /></td>
          <td width="20%"><span class="camposss">Dia:</span> </td>
          <td width="31%"><input name="fecrecogio" type="text" id="fecrecogio" style="text-transform:uppercase" size="15" class="tcal" /></td>
        </tr>
        <tr>
          <td><span class="camposss">Nro Fac/Bol:</span></td>
          <td><input name="factura" type="text" id="factura" style="text-transform:uppercase" size="30" maxlength="400" /></td>
          <td colspan="2"></td>
          </tr>
      </table>
    </fieldset></td>
    </tr>
  <tr>
    <td height="30" colspan="2" align="right" >&nbsp;</td>
  </tr>
</table>
</div>
</body>
</html>